#ifndef __FLASH_BOARD_H__
#define __FLASH_BOARD_H__

#include "system.h"
#include "tremo_regs.h"
#include "tremo_flash.h"

// #define CONFIG_FLASH_PROCESS_RAM                 //使用内存的方式操作flash
#define CONFIG_FLASH_PROCESS_FLASH               //使用flash备份的方式操作flash


/*
 *flash区域分配，一共128字节
 * 系统程序区           116
 * 参数区               4K
 * 参数备份区           4K
 * falsh操作temp区      4K
*/




#define CHIP_FLASH_SIZE                 (128*1024)     
#define SYSTEM_APP_PROGRAM_ADDR         (FLASH_BASE)     
#define SYSTEM_APP_PROGRAM_SIZE         (116*1024)


#define EEPROM_TOTAL_SIZE				(FLASH_PAGE_SIZE)
#define SYSTEM_PARAM_DATA_ADDR	        (SYSTEM_APP_PROGRAM_ADDR + SYSTEM_APP_PROGRAM_SIZE)
#define SYSTEM_PARAM_DATA_LEN			(FLASH_PAGE_SIZE)

#define SYSTEM_PARAM_DATA_BACKUP_ADDR	(SYSTEM_PARAM_DATA_ADDR + SYSTEM_PARAM_DATA_LEN)
#define SYSTEM_PARAM_DATA_BACKUP_LEN	(FLASH_PAGE_SIZE)


#define FLASH_PROCESS_BACKUP_ADDR       (SYSTEM_PARAM_DATA_BACKUP_ADDR +SYSTEM_PARAM_DATA_BACKUP_LEN)  
#define FLASH_PROCESS_BACKUP_SIZE       (FLASH_PAGE_SIZE) 

void FlashInit(void);

int EepromReadData(uint32_t ReadAddress,uint8_t* readBuffer, uint16_t readNum);

int EepromWriteData(uint32_t writeAddress,uint8_t* writeBuffer, uint16_t writeNum);
int EepromWriteData2(uint32_t writeAddress,uint8_t* writeBuffer, uint16_t writeNum);

#endif
